﻿@{
    ViewBag.Title = "Tổng đài chém gió";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet">
                <div class="portlet-title">
                    <h4>
                        <i class="icon-comments"></i>
                        Tổng đài chém gió
                    </h4>
                </div>
            </div>
            <div class="portlet-body" id="chats">
                <div class="scroller" data-height="343px" data-always-visible="1" data-rail-visible1="1">
                    <ul class="chats">

                    </ul>
                </div>
                <div class="chat-form">
                    <form id="chatsubmit" action="javascript:;">
				        <div class="input-cont">   
					        <input id="message" type="text" placeholder="Nhập tin nhắn vào đây..." class="m-wrap">
				        </div>
				        <div class="btn-cont"> 
					        <span class="arrow"></span>
					        <button class="btn blue icn-only" type="submit" id="sendmessage"><i class="icon-ok icon-white"></i></button>
				        </div>
                    </form>
			    </div>
            </div>
        </div>
    </div>
</div>
<ul class="hide" id="chatrow">
    <li class="in">
        <img src="~/Images/trung.jpg" alt="" class="avatar img-responsive">
        <div class="message">
            <span class="arrow"></span>
            <a class="name" href="#"></a>
            <span class="datetime">at Jul 25, 2012 11:09</span>
            <span class="body">
            </span>
        </div>
    </li>
</ul>
<script src="~/Scripts/jquery.signalR-2.0.0.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="~/signalr/hubs"></script>
<!--SignalR script to update the chat page and send messages.--> 
<script>
    $(function () {
        // Reference the auto-generated proxy for the hub.  
        var chat = $.connection.chatHub;
        // Create a function that the hub can call back to display messages.
        chat.client.addNewMessageToPage = function (name, message) {
            $('#chatrow a.name').html(name);
            $('#chatrow span.body').html(message);
            $('#chats ul.chats').append($('#chatrow').html());
            $('.scroller').slimScroll({ scrollTo: $('#chats ul.chats')[0].scrollHeight });
        };
        // Set initial focus to message input box.  
        $('#message').focus();
        // Start the connection.
        $.connection.hub.start().done(function () {
            $('#chatsubmit').submit(function () {
                // Call the Send method on the hub. 
                chat.server.send('@ViewBag.FullName', $('#message').val());
                // Clear text box and reset focus for next comment. 
                $('#message').val('').focus();
                return false;
            });
        });
    });
    // This optional function html-encodes messages for display in the page.
    function htmlEncode(value) {
        var encodedValue = $('<div />').text(value).html();
        return encodedValue;
    }
</script>